feat(models): implement Transfer model and TransferStatus enum - #50
Conversation
Adds src/shade/models/transfer.py following the pydantic ShadeObject pattern used by Merchant: camelCase API fields are aliased to snake_case, amount/fee are Decimal, status is coerced to a TransferStatus enum, and asset falls back to "XLM" when absent or null. Closes ShadeProtocol#40
|
Warning Review limit reached
Next review available in: 49 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughChangesTransfer model
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant APIResponse
participant Transfer.from_dict
participant PydanticValidators
APIResponse->>Transfer.from_dict: camelCase transfer payload
Transfer.from_dict->>PydanticValidators: mapped model fields
PydanticValidators-->>Transfer.from_dict: validated Transfer instance
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/shade/models/transfer.py`:
- Around line 50-55: The _default_asset validator currently converts malformed
falsy values such as False and 0 to XLM. Update its fallback condition to apply
only when value is None or an empty string, while preserving valid non-empty
asset strings unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 67522adc-46ce-4f08-85ca-cef358f4e0f6
📒 Files selected for processing (4)
src/shade/__init__.pysrc/shade/models/__init__.pysrc/shade/models/transfer.pytests/test_transfer.py
Addresses CodeRabbit review on ShadeProtocol#50: the asset default validator only covers None and "" now, so False/0 correctly fail type validation instead of being silently normalized to "XLM".
codebestia
left a comment
There was a problem hiding this comment.
LGTM!
Nice Implementation.
Thank you for your contribution.
Description
Implements the
Transfermodel as specced in #40: represents a payout of funds from the merchant wallet to a destination address, following the same pydanticShadeObjectpattern established byMerchant(camelCase API fields aliased to snake_case,extra="allow"for forward compatibility,pydantic.ValidationErrorwrapped intoInvalidRequestError).src/shade/models/transfer.py:Transfermodel withid,source_address,destination_address,amount: Decimal,asset: str,status: TransferStatus,stellar_tx_hash: Optional[str],fee: Optional[Decimal],created_at: datetime.TransferStatusenum:pending,processing,completed,failed.assetdefaults to"XLM"both when the key is absent and when the API sends an explicitnull.source_address/destination_addressare validated as Stellar ed25519 public keys, matchingMerchant.address.shade.modelsand the top-levelshadepackage.Fixes #40
Type of change
How Has This Been Tested?
tests/test_transfer.pycovering all three acceptance criteria plus edge cases (missingasset/fee, nullasset, invalidstatus, invalid addresses, non-positiveamount, negativefee, missingid, unknown-field passthrough, dict round-trip).pytest -q— 196 passed, 3 skipped (full existing suite + 17 new tests).flake8 src tests --select=E9,F63,F7,F82— clean.Checklist:
Summary by CodeRabbit